package com.material.controller.supplier;

import com.material.common.annotation.LoginUser;
import com.material.common.core.domain.entity.SysUser;
import com.material.common.entity.ResultResponse;
import com.material.factory.domain.FactoryFuel;
import com.material.factory.service.IFactoryFuelService;
import com.material.supplier.domain.SupplierInfo;
import com.material.supplier.service.ISupplierInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author ganxinge
 */
@Api(tags = "7.燃料品名")
@RestController
@RequestMapping("/fuel")
public class FactoryFuelController {

    @Autowired
    private IFactoryFuelService factoryFuelService;
    @Autowired
    private ISupplierInfoService supplierInfoService;

    @ApiOperation("燃料品名列表")
    @GetMapping("/list")
    public ResultResponse list(@ApiIgnore @LoginUser SysUser sysUser){
        Long supplierId = sysUser.getBizId();
        SupplierInfo supplierInfo = supplierInfoService.selectSupplierInfoById(supplierId);
        FactoryFuel query = new FactoryFuel();
        query.setFactoryId(supplierInfo.getFactoryId());
        List<FactoryFuel> factoryFuels = factoryFuelService.selectFactoryFuelList(query);
        return ResultResponse.success(factoryFuels);
    }
}
